package org.btik.light.server.platform.common.api.bean.dev.access;

import org.btik.light.cache.CurrentMemCachePo;
import org.btik.light.tool.MDUtil;
import org.springframework.beans.BeanUtils;

import java.util.Objects;

/**
 * 设备接入账号
 */
public class DevAccount implements CurrentMemCachePo<DevAccount> {

    private String username;

    private String passwd;

    private MDUtil.Algorithm mdAlgorithm;

    private Boolean status = true;


    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public MDUtil.Algorithm getMdAlgorithm() {
        return mdAlgorithm;
    }

    public void setMdAlgorithm(MDUtil.Algorithm mdAlgorithm) {
        this.mdAlgorithm = mdAlgorithm;
    }

    @Override
    public String key() {
        return getUsername();
    }

    @Override
    public void setKey(String key) {
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    @Override
    public DevAccount copy(DevAccount po) {
        this.passwd = po.passwd;
        this.mdAlgorithm = po.mdAlgorithm;
        this.status = po.status;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof DevAccount that)) return false;
        return Objects.equals(getUsername(), that.getUsername()) && Objects.equals(getPasswd(), that.getPasswd()) && getMdAlgorithm() == that.getMdAlgorithm() && Objects.equals(getStatus(), that.getStatus());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getUsername(), getPasswd(), getMdAlgorithm(), getStatus());
    }

    @Override
    public DevAccount newCopy() {
        DevAccount devAccount = new DevAccount();
        BeanUtils.copyProperties(this,devAccount);
        return devAccount;
    }
}
